package com.laolei.feign;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.laolei.feign.api.YoudaoApi;

@EnableFeignClients
@SpringBootApplication
public class SpringFeignConfigApplication {
	
	@Bean RestTemplate restTemplate(ObjectMapper objectMapper) {
		RestTemplate restTemplate=new RestTemplate();
		restTemplate.getMessageConverters().add(new AbstractJackson2HttpMessageConverter(objectMapper,MediaType.TEXT_PLAIN) { });
		return restTemplate;
	}
	
	public static void main(String[] args) {
		YoudaoApi youdaoApi=SpringApplication.run(SpringFeignConfigApplication.class, args).getBean(YoudaoApi.class);
		System.err.println(youdaoApi.fanyi("good", "test12343534534", "905632735", "data", "json"));
	}
}
